
package Modelo;

import Controlador.MotorSemaforo;
import java.awt.Color;
import java.awt.Graphics;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;


public class Semaforo extends Figuras  {

  Vector<Figuras> fig;
  protected MotorSemaforo moto;
  
    public Semaforo(Integer id0, Integer x0,Integer y0,Integer w0,Integer h0,Color c,Integer vida, Boolean estado,Vector<Figuras> fi){

	     super(id0, x0,y0,h0,w0,c,vida,estado);
             fig=fi;            
             moto = new MotorSemaforo(this,fig);
             moto.start();
    }

    @Override
    public void dibujar(Graphics g) {
        g.setColor(Color.red);
        g.fillRect(x, y, ancho, alto);
    }

    @Override
    public void colision(Figuras figura) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void colision(Autito a) {

     a.rebota();
    }

    @Override
    public void colision(Pared pared) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override

    public synchronized void  colision(Policia p) {
     
     
          try {
             wait();
            
        } catch (Exception ex) {
            Logger.getLogger(Semaforo.class.getName()).log(Level.SEVERE, null, ex);
       }
          p.motor.notifyAll();
    }

    

    @Override
    public void colision(Base base) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void colision(Destino destino) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public void colision(Semaforo semaforo) {
        throw new UnsupportedOperationException("Not supported yet.");
    }
public synchronized void noti(){

    notifyAll();
}


 }